#include<bits/stdc++.h>
using namespace std;
const int N = 5e5+10;
int n,k;
int idx[N];
long double px[N];
long double py[N];
bool cmp1(int x,int y){
    return px[x] < px[y];
}
bool cmp2(int x,int y){
    return py[x] < py[y];
}
priority_queue<long double,vector<long double>,greater<long double>> que;
struct KDT{
    int ls[N],rs[N];
    struct zone{
        long double x1,x2,y1,y2;
        friend zone operator+(zone va,zone vb){
            return {min(va.x1,vb.x1),max(va.x2,vb.x2),min(va.y1,vb.y1),max(va.y2,vb.y2)};
        }
    };
    zone zs[N];
    int build(int l,int r,int p){
        if(r < l){
            return 0;
        }
        if(l == r){
            int now = idx[l];
            zs[now] = {px[now],px[now],py[now],py[now]};
            return now;    
        }
        int mid = (l + r)/2;
        if(p){
            nth_element(idx + l,idx + mid,idx + r,cmp1);
        }else{
            nth_element(idx + l,idx + mid,idx + r,cmp2);
        }
        int now = idx[mid];
        ls[now] = build(l,mid - 1,(p + 1)&1);
        rs[now] = build(mid+1,r,(p + 1)&1);
        if(!ls[now] || !rs[now]){
            zs[now] = zs[ls[now] + rs[now]];
        }else{
            zs[now] = zs[ls[now]] + zs[rs[now]];
        }
        zs[now] = zs[now] + (zone){px[now],px[now],py[now],py[now]};
        return now;
    }
    long double dis(long double x1,long double y1,long double x2,long double y2){
        return 1ll*(x1 - x2)*(x1 - x2) + 1ll*(y1 - y2)*(y1 - y2);
    }
    long double madis(zone va,long double x,long double y){
        return max(max(dis(va.x1,va.y1,x,y),dis(va.x1,va.y2,x,y)),max(dis(va.x2,va.y1,x,y),dis(va.x2,va.y2,x,y)));
    }
    void query(int now,long double x,long double y){
        if(!now)return;
        if(que.size() < k || dis(x,y,px[now],py[now]) > que.top()){   
            if(que.size() == k){
                que.pop();
            }
            que.push(dis(x,y,px[now],py[now]));
        }
        if(ls[now] && rs[now]){
            if(madis(zs[ls[now]],x,y) < madis(zs[rs[now]],x,y)){
                chkquery(rs[now],x,y);
                chkquery(ls[now],x,y);
            }else{
                chkquery(ls[now],x,y);
                chkquery(rs[now],x,y);
            }
        }else{
            chkquery(ls[now] + rs[now],x,y);
        }
    }
    inline void chkquery(int now,long double x,long double y){
        if(now && (que.size() < k || madis(zs[now],x,y) > que.top())){
            query(now,x,y);
        }
    }
}kdt;
random_device rd;
int main(){
    cin>>n>>k;
    k*=2;
    int val = rd()%200;
    for(int i = 1;i<=n;i++){
        idx[i] = i;
        long double x,y;
        cin>>x>>y;
        px[i] = x*cosl(1.0*val) + y*sinl(1.0*val);
        py[i] = -sinl(1.0*val)*x + y*cosl(1.0*val);
        cerr<<px[i]<<' '<<py[i]<<'\n';
    }
    int rot = kdt.build(1,n,0);
    for(int i = 1;i<=n;i++){
        kdt.chkquery(rot,px[i],py[i]);
    }
    cout<<((long long)que.top())<<'\n';
}